package com.moli.iov.notify.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.notify.enums.StatusEnum;
import com.moli.iov.notify.mapper.NoticeAlarmMapper;
import com.moli.iov.notify.model.dto.NoticeAlarmDto;
import com.moli.iov.notify.model.po.NoticeAlarm;
import com.moli.iov.notify.service.INoticeAlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author wanghualin
 * @since 2019-10-08
 */
@Service
public class NoticeAlarmServiceImpl extends ServiceImpl<NoticeAlarmMapper, NoticeAlarm> implements INoticeAlarmService {


    @Autowired
    private NoticeAlarmMapper noticeAlarmMapper;

    @Override
    public List<NoticeAlarmDto> queryAllNoticeAlarmByProperties(NoticeAlarmDto noticeAlarmDto){
        return noticeAlarmMapper.queryAllNoticeAlarmByProperties(noticeAlarmDto);
    }

    @Override
    public Boolean updateMailUsedAndSmsUsedById(NoticeAlarmDto noticeAlarmDto){
        return noticeAlarmMapper.updateMailUsedAndSmsUsedById(noticeAlarmDto);
    }

    @Override
    public NoticeAlarm queryNoticeAlarmByProperties(Long companyId, Integer alarmTypeId, Integer alarmLevelId){
        QueryWrapper<NoticeAlarm> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(NoticeAlarm::getCompanyId, companyId)
                .eq(NoticeAlarm::getAlarmTypeId, alarmTypeId)
                .eq(NoticeAlarm::getAlarmLevelId, alarmLevelId)
                .eq(NoticeAlarm::getIsDelete, StatusEnum.NO.getFlag());
        return this.getOne(queryWrapper);
    }

}
